<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 对象添加Symbol类型的属性方法

        // 方法1
        // 声明一个目标obj
        let game = {};

        // 声明一个对象
        let methods = {
            up: Symbol('up'),
            down: Symbol('down'),

        }

        // 把声明的对象中的方法扩展给目标Obj
        // 即给game添加方法
        game[methods.up] = function () { console.log('up'); };
        game[methods.down] = function () { console.log('down'); };

        console.log(game);

        // 方法2
        let youxi = {
            name: '狼人杀',
            [Symbol('say')]: function () {
                console.log('一句话');
            },
            [Symbol('kill')]: function () {
                console.log('刀人');
            },
        }

        console.log(youxi);
    </script>
</body>

</html>